#include "ItemInventory.h"

#include "../StringHelper.h"
#include "../CommandManager.h"
#include "../GameObjects/Room.h"
#include "../GameObjects/Character.h"
#include "../GameObjects/Item.h"
#include "../Player.h"

#include <iostream>
#include <algorithm>

void ItemInventory::Init()
{
	CommandManager::getSingleton()->add(std::make_shared<Inventory>());
}

///////////////////////////////////////
// INVENTORY
///////////////////////////////////////
Inventory::Inventory() : Command("inventory")
{
	add("inv");
}
void Inventory::execute(const CharacterPtr &character, const RoomPtr &/*room*/, const std::vector<std::string> &args)
{
	if(args.empty())
	{
		if(character->hasPlayer())
		{
			if(character->getItems().empty())
			{
				std::cout << "Your pockets are all empty." << std::endl;
			}
			else
			{
				std::cout << "You peek inside your pockets and find" << std::endl;
				std::for_each(begin(character->getItems()), end(character->getItems()), [](const ItemPtr &item)
				{
					item->look();
				});
			}
		}
		return;
	}

	if(character->hasPlayer())
		std::cout << "You don't know how to do that!" << std::endl;
}
